import cfg from "../config.js"
import page from "../page.js"


let page_type = {
  open: function (page_info) {
    let page_html_id=page_info.page_html_id;
      let property=page_info.property;
      let ext_js=page_info.ext_js;
      let page_id=page_info.page_id;
      let rights=page_info.rights;
      let params=page_info.params;
      $("#" + page_html_id).html("\
      <div class='col-ld-2 col-md-2 col-sm-2 col-xs-2'>\
      </div>\
      <div class='col-ld-8 col-md-8 col-sm-8 col-xs-8'>\
          <div class='view-part form-process-part'></div>\
      </div>\
      <div class='col-ld-2 col-md-2 col-sm-2 col-xs-2'>\
      </div>"
      );

      function open_edit_page(a,b){

        page.open_by_type(page_html_id, b.scope.process, b,'');

      }

      let amisJSON=
      {
          "type": "page",
          "body": 
            {
              "type":"form",
              "className":"text-xl",
              "title": "选择",
              "mode": "horizontal",
              "horizontal": {
                "left": "col-sm-1",
                "right": "col-sm-10",
                "offset": "col-sm-offset-2"
              },
              "actions": [
                {
                  "type": "reset",
                  "label": "重置"
                },
                {
                  "type": "submit",
                  "level": "primary",
                  "label": "确定",
                  "onClick": (a, b) => open_edit_page(a,b)
                }
              ],
              "body":
              [
                {
                  "type": "select",
                  "name": "resource",
                  "label": "产线",
                  "required": true,
                  "className":"font-bold	",
                  "source": {
                    "method": "post",
                    "url":  cfg.api_server +"mes/mesprocess/resources"
                  },
                  "autoFill": {
                    "related_resource": "${label}"
                  }

                },
                {
                  "type": "select",
                  "name": "process",
                  "label": "工序",
                  "className":"font-bold	",
                  "required": true,
                  "source": {
                    "method": "post",
                    "url": cfg.api_server +"mes/mesprocess/process?resourceName=${related_resource}"
                  },
                  "autoFill": {
                    "related_process": "${label}"
                  }
                },
                {
                  "type": "select",
                  "name": "station",
                  "label": "工位",
                  "className":"font-bold	",
                  "required": true,
                  "source": {
                    "method": "post",
                    "url": cfg.api_server +"mes/mesprocess/station?resourceName=${related_resource}&processName=${related_process}"
                  }
                }
              ]
            }
      
      };
      let amis = amisRequire('amis/embed');
        let view_amisScoped = amis.embed(
            '#' + page_html_id + " .form-process-part", amisJSON, {},
            {
                theme: 'antd'
            }
        );

    }
  }
  
  export default page_type;